<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;
use app\helper\CommonHelper;

final class CreateDataTable extends AbstractMigration
{
    public function up()
    {
        // 初始化用户表
        $table = $this->table('rp_user');
        $password = CommonHelper::get_rand_str();
        $file = fopen("database/secret.txt", "w");
        fwrite($file, "进入系统后请及时修改账号密码并【删除该文件】\r\n账号：admin，密码：" . $password);
        fclose($file);
        $userRow = [
            'id' => 1,
            'username' => 'admin',
            'password' => md5($password),
            'headimg' => 'http://baidu.com',
        ];
        $table->insert($userRow);
        $table->saveData();

        // 初始化站点表
        $table = $this->table('rp_sites');
        $sitesRow = [
            [
                'site_name' => '象站',
                'site_url' => 'https://ptvicomo.net',
                'api_url' => 'https://ptvicomo.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '铃音',
                'site_url' => 'https://pt.soulvoice.club',
                'api_url' => 'https://pt.soulvoice.club/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'carpt',
                'site_url' => 'https://carpt.net',
                'api_url' => 'https://carpt.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '蚂蚁',
                'site_url' => 'https://hdmayi.com',
                'api_url' => 'https://hdmayi.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '蝶粉',
                'site_url' => 'https://discfan.net',
                'api_url' => 'https://discfan.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'ilolicon',
                'site_url' => 'https://share.ilolicon.com',
                'api_url' => 'https://share.ilolicon.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '大青虫',
                'site_url' => 'https://cyanbug.net',
                'api_url' => 'https://cyanbug.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '3wmg',
                'site_url' => 'https://www.3wmg.com',
                'api_url' => 'https://www.3wmg.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '阿童木',
                'site_url' => 'https://hdatmos.club',
                'api_url' => 'https://hdatmos.club/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '2xfree',
                'site_url' => 'https://pt.2xfree.org',
                'api_url' => 'https://pt.2xfree.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '明教',
                'site_url' => 'https://hdpt.xyz',
                'api_url' => 'https://hdpt.xyz/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'oshen',
                'site_url' => 'https://www.oshen.win',
                'api_url' => 'https://www.oshen.win/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '冬樱',
                'site_url' => 'https://wintersakura.net',
                'api_url' => 'https://wintersakura.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'rousi',
                'site_url' => 'https://rousi.zip',
                'api_url' => 'https://rousi.zip/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '咖啡',
                'site_url' => 'https://ptcafe.club',
                'api_url' => 'https://ptcafe.club/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '1ptba',
                'site_url' => 'https://1ptba.com',
                'api_url' => 'https://1ptba.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '农场',
                'site_url' => 'https://pt.0ff.cc',
                'api_url' => 'https://pt.0ff.cc/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '你堡',
                'site_url' => 'https://ubits.club',
                'api_url' => 'https://ubits.club/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'kufei',
                'site_url' => 'https://kufei.org',
                'api_url' => 'https://kufei.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'icc',
                'site_url' => 'https://www.icc2022.com',
                'api_url' => 'https://www.icc2022.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '憨憨',
                'site_url' => 'https://hhanclub.top',
                'api_url' => 'https://hhanclub.top/nexusapi/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'ptlsp',
                'site_url' => 'https://www.ptlsp.com',
                'api_url' => 'https://www.ptlsp.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'hdtime',
                'site_url' => 'https://hdtime.org',
                'api_url' => 'https://hdtime.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'zmpt(织梦)',
                'site_url' => 'https://zmpt.cc',
                'api_url' => 'https://zmpt.cc/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'ultrahd',
                'site_url' => 'https://ultrahd.net',
                'api_url' => 'https://ultrahd.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '猪猪',
                'site_url' => 'https://piggo.me',
                'api_url' => 'https://api.piggo.me/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '红叶',
                'site_url' => 'https://leaves.red',
                'api_url' => 'https://leaves.red/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'okpt',
                'site_url' => 'https://www.okpt.net',
                'api_url' => 'https://www.okpt.net/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'ggpt',
                'site_url' => 'https://gamegamept.com',
                'api_url' => 'https://gamegamept.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'oldtoons',
                'site_url' => 'https://oldtoon.world',
                'api_url' => 'https://oldtoon.world/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '麒麟',
                'site_url' => 'https://www.hdkyl.in',
                'api_url' => 'https://www.hdkyl.in/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'agsv',
                'site_url' => 'https://www.agsvpt.com',
                'api_url' => 'https://www.agsvpt.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '红豆饭',
                'site_url' => 'https://hdfans.org',
                'api_url' => 'https://hdfans.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '超科学PT喵',
                'site_url' => 'https://ptneko.com',
                'api_url' => 'https://ptneko.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '悟空问道',
                'site_url' => 'https://wukongwendao.top',
                'api_url' => 'https://wukongwendao.top/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '兽站',
                'site_url' => 'https://pt.hd4fans.org',
                'api_url' => 'https://pt.hd4fans.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '可鲁',
                'site_url' => 'https://our.kelu.one',
                'api_url' => 'https://our.kelu.one/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => 'kamept',
                'site_url' => 'https://kamept.com',
                'api_url' => 'https://kamept.com/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '铂金学院',
                'site_url' => 'https://ptchina.org',
                'api_url' => 'https://ptchina.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '超分辨率',
                'site_url' => 'https://srvfi.top',
                'api_url' => 'https://srvfi.top/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '蟹黄堡',
                'site_url' => 'https://crabpt.vip',
                'api_url' => 'https://crabpt.vip/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '青蛙',
                'site_url' => 'https://new.qingwa.pro',
                'api_url' => 'https://new.qingwa.pro/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ],
            [
                'site_name' => '花梨月下（ecustpt）',
                'site_url' => 'https://public.ecustpt.eu.org',
                'api_url' => 'https://public.ecustpt.eu.org/api/pieces-hash',
                'passkey' => '',
                'download_limit' => 0,
                'upload_limit' => 0,
                'status' => 1,
            ]
        ];
        $table->insert($sitesRow);
        $table->saveData();

    }
}
